package com.haha.community.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.haha.community.entity.Message;
import com.haha.community.dao.MessageMapper;
import com.haha.community.service.MessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yang
 * @since 2020-10-30
 */
@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {

    @Override
    public int findConversationCount(Integer id) {
        return baseMapper.selectConversationCount(id);
    }

    @Override
    public List<Message> findConversations(Integer id, int offset, int limit) {
        return baseMapper.selectConversations(id,offset,limit);
    }

    @Override
    public Integer findLetterCount(String conversationId) {
        return baseMapper.selectLetterCount(conversationId);
    }

    @Override
    public int findLetterUnreadCount(Integer id, String conversationId) {
        return baseMapper.selectLetterUnreadCount(id,conversationId);
    }

    @Override
    public List<Message> findLetters(String conversationId, int offset, int limit) {
        return baseMapper.selectLetters(conversationId, offset, limit);
    }

    @Override
    public void readMessage(List<Integer> ids) {
        baseMapper.updateStatus(ids,1);
    }

    @Override
    public void addMessage(Message message) {
        baseMapper.insert(message);
    }
}
